﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MarchEstate.Manager.BusinesEntity;
using MarchEstate.Manager.Dao.Room;

namespace MarchEstate.Manager.ObjectModel.Room
{
    public class ShopManager : AbstractShop, IJoinManager
    {
        private AreaRoomDao areaRoomDao = null;

        public ShopManager()
        {

        }
        public override void InitDao()
        {
            base.InitDao();
            areaRoomDao = NewDao<AreaRoomDao>();
        }
        #region IJoinManager 成员

        public bool Join(System.Collections.Hashtable value)
        {
            string srccId = value["srccId"].ToString();
            return areaRoomDao.JoinShop(srccId);
        }

        public bool CancelJoin(string srccId)
        {
            return areaRoomDao.CancelJoinShop(srccId);
        }

        #endregion


        public override bool Delete(string _shopid)
        {
            return areaRoomDao.DeleteShop(_shopid);
        }

        public override bool Save(List<string> _roomIdList, List<string> _roomNumberList)
        {
            if (this.ShopId == null || this.ShopId == "")
            {
                return areaRoomDao.AddShop(this, _roomIdList, _roomNumberList) > 0;
            }
            else
            {
                return areaRoomDao.UpdateShop(this, _roomIdList, _roomNumberList) > 0;
            }
            return true;
        }

        public override List<AbstractRoom> GetShopsRoomList(string _shopId)
        {
            return areaRoomDao.GetShopsRoomList(_shopId);
        }

        public override System.Data.DataTable GetShopAndOwnerList(string shopname, CoreFrame.Core.Orm.PageInfo page)
        {
            return areaRoomDao.GetShopAndOwnerList(shopname, page);
        }
    }
}
